<?php
	/**
	* Edit action
	* @author tunv
	* @since Apr 4, 2012
	* 
	* Change logs
	* 
	*/
	if (!defined('EXPONENT')) exit('');
	// $id -> state
	// 
	$cat_id=0;
	$company = null;
	if (isset($_REQUEST['id']))
	{
		$cat_id = intval($_REQUEST['id']);
		$company  = $db->selectObject('surveymodule_companies',"id=".$cat_id);
		$loc = unserialize($company->location_data);
	}
	if (exponent_permissions_check(array('administrate','configure','create'),$loc)) 
	{   
		$form = surveymodule_cat::company_form($company);
		$form->location($loc);
		$form->meta('action','company_save');
		$template = new template('surveymodule','_company_edit');
		$template->assign('is_edit',(isset($company->id)? 1 : 0));
		$template->assign('form_html',$form->toHTML());
		$template->output();

	}
	else 
	{
		echo SITE_404_HTML;
	}
?>